package com.shujia.MR.join;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class JoinReducer extends Reducer<Text, Text, Text, Text> {
    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String studentInfo = null;
        String studentScore = null;

        for (Text value : values) {
            if (value.toString().contains("*")) {
                studentInfo = value.toString();
            } else {
                studentScore = value.toString();
            }
        }
        context.write(key, new Text(studentInfo + "*" + studentScore));
    }
}
